<?php

namespace App\depository;

use App\Enum\PermissionsEnum;
use App\Models\RoleHasPermissionsModel;

class RoleHasPermissionsDep
{
    public $model;

    public function __construct(){
        $this->model = new RoleHasPermissionsModel();
    }

    public function add($data){
        $res = $this->model->insert($data);
        return $res;
    }

    public function addGetId($data){
        $res = $this->model->insertGetId($data);
        return $res;
    }

    public function upd($id,$data){
        $res = $this->model->where('id',$id)->update($data);
        return $res;
    }

    public function del($id){
        $res = $this->model->where('id',$id)->delete();
        return $res;
    }

    public function getByRoleId($roleId){
        $res = $this->model->where('role_id',$roleId)->get();
        return $res;
    }

    public function delByRoleId($roleId){
        $res = $this->model->where('role_id',$roleId)->delete();
        return $res;
    }
}
